package pms.common.utils;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class PMSLog {
		
	// ロガーの初期化
	static Log systemLogger = LogFactory.getLog("system_error");		// システムエラーロガー
	static Log businessLogger = LogFactory.getLog("business_error");	// 業務エラーロガー
	static Log debugLogger = LogFactory.getLog("debug");			// デバッグロガー
	static Log sqlLogger  = LogFactory.getLog("sql");				// SQLロガー
	static Log userLogger = LogFactory.getLog("trace");				// ユーザ操作ロガー
	
	public static void systemError(String msg) {
		systemLogger.fatal(msg);
	}
	
	public static void businessError(String msg) {
		businessLogger.error(msg);
	}
	
	public static void debug(String msg) {
		StackTraceElement l_st = Thread.currentThread().getStackTrace()[3];
		debugLogger.debug(l_st.getClassName()+"."+l_st.getMethodName()+"->"+msg);
	}
	
	public static void sql(String msg) {
		sqlLogger.debug(msg);
	}
	
	public static void info(String msg) {
		userLogger.info(msg);
	}
	
	public static void start() {
		StackTraceElement l_st = Thread.currentThread().getStackTrace()[3];
		userLogger.info(l_st.getClassName() + "." +l_st.getMethodName() + "メソッド開始");
	}
	
	public static void end() {
		StackTraceElement l_st = Thread.currentThread().getStackTrace()[3];
		userLogger.info(l_st.getClassName() + "." +l_st.getMethodName() + "メソッド終了");
	}
}
